
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Krile.Kernel.Bridges
{
    public interface IMainForm// : IForm
    {
        /// <summary>
        /// Add tab to main form
        /// </summary>
        void AddTab();

        /// <summary>
        /// Add tab to main form
        /// </summary>
        /// <param name="name">tab name</param>
        /// <param name="cluster">tab clusters</param>
        /// <param name="serviceIds">linking service ids(this use for input select on initialize)</param>
        void AddTab(string name, Data.SearchDataCluster cluster, string[] serviceIds);

        /// <summary>
        /// Append inherited tab from selected tab
        /// </summary>
        /// <param name="name">new name</param>
        /// <param name="AddSearchDatas">searchdata which appends original data</param>
        void AddInheritedTab(string name, Krile.Kernel.Data.SearchDataBase[] AddSearchDatas);

        /// <summary>
        /// Append menu item for plugin-item 
        /// </summary>
        /// <param name="plugin">plugin instance</param>
        /// <param name="menuitem">menu item</param>
        void AddPluginMenu(Plugin.IPlugin plugin, ToolStripMenuItem menuitem);

        /// <summary>
        /// Add custom menu item to context menu candidates
        /// </summary>
        /// <param name="candidate">custom candidate item</param>
        void AddCustomContextMenuCandidate(CustomContextMenuCandidate candidate);

        /// <summary>
        /// Set status-text
        /// </summary>
        /// <param name="text">text</param>
        void SetStatusText(string text);

        /// <summary>
        /// Set status-text
        /// </summary>
        /// <param name="text">text</param>
        /// <param name="showlen">show length(sec)</param>
        void SetStatusText(string text, int showlen);

        /// <summary>
        /// Show back-status text
        /// </summary>
        /// <param name="text">text</param>
        /// <param name="keepalive">if you want disable auto-delete, set this para true.</param>
        void SetBackStatusText(string text, bool keepalive);

        /// <summary>
        /// Append child-form to input method manager.
        /// <para>If you want to use form for helping input, you should NOT use this method but use InputCOntrolManager.AppendChild().</para>
        /// </summary>
        /// <param name="childForm">child form</param>
        void AppendChild(Form childForm);

        /// <summary>
        /// Static reference to PARENT FORM'S ICM.(NOT CURRENT ICM!)
        /// </summary>
        IInputControlManager InputControlManager { get; }

        object SafeOperate(Delegate delg, params object[] args);

        object SafeOperate(Action delg);

        object SafeOperate<T>(Action<T> delg, T args);
    }

    public abstract class CustomContextMenuCandidate
    {
        /// <summary>
        /// Get supposed menu item
        /// </summary>
        /// <returns></returns>
        public abstract ToolStripMenuItem GetMenuItem();

        /// <summary>
        /// Check show this menuitem
        /// </summary>
        /// <param name="selected">current selected status</param>
        /// <returns>if krile should show this menu, returns true</returns>
        public abstract bool IsShowMenu(Data.Status selected);
    }
}
